#include <QtWidgets/QApplication>
#include <QtWidgets/QWidget>
#include <QtGui/QPainter>
#include <QtGui/QPen>

class ShapesWidget : public QWidget {
protected:
    void paintEvent(QPaintEvent *event) override {
        QPainter painter(this);

        // 设置画笔
        QPen pen(Qt::blue, 5);
        painter.setPen(pen);

        // 绘制圆
        QRect rect1(10, 10, 100, 100);
        painter.drawEllipse(rect1);

        // 修改画笔颜色并绘制椭圆
        pen.setColor(Qt::red);
        painter.setPen(pen);
        QRect rect2(120, 10, 150, 100);
        painter.drawEllipse(rect2);

        // 修改画笔颜色并绘制三角形
        pen.setColor(Qt::green);
        painter.setPen(pen);
        QPolygon polygon;
        polygon << QPoint(280, 110) << QPoint(380, 110) << QPoint(330, 10);
        painter.drawPolygon(polygon);
    }
};

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    
    ShapesWidget widget;
    widget.resize(400, 200);
    widget.show();

    return app.exec();
}